package your.rpg.namespace;

import java.io.IOException;

//this class creates the levels and changes current level
public class LevelLoader {
	private LevelData _leveldata;
	private LevelFileReader filereader;
	
	public LevelLoader(LevelData data){
		_leveldata = data;
	}
	
	public void setFileReader(LevelFileReader reader){
		filereader = reader;
	}
	
	public void processLevel(String levelid) throws IOException{
		if(_leveldata.findLevel(0) == false)
		{
			String filename = "level" + levelid;
			filereader.readFileLevel(filename,Integer.parseInt(levelid));
			filereader.readFileObject(filename+"_objects",Integer.parseInt(levelid));
			filereader.readFileEvent(filename+"_events",Integer.parseInt(levelid));
		}
	}
	
	public void addLevel(int id, int imageid, String levelname, int move1, int move2, int move3, String point1, String point2, String point3){
		_leveldata.addLevel(id, imageid, levelname, move1, move2, move3, point1, point2, point3);
	}
	
	public void addEvent(int id, String listname, String content){
		_leveldata.addEvent(id,listname,content);
	}
	
	public void addObject(int id, String name, int imageid, int x, int y){
		_leveldata.addObject(id, name, imageid, x, y);
	}
}
